home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / Clueless.swf / scripts / PowerupReshuffle.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  3.1 KB  |  90 lines

  1. package
  2. {
  3.    import Common.SoundManager;
  4.    import Forms.DressupForm;
  5.    import flash.utils.setTimeout;
  6.    import org.flintparticles.actions.Accelerate;
  7.    import org.flintparticles.actions.Age;
  8.    import org.flintparticles.actions.Fade;
  9.    import org.flintparticles.actions.Move;
  10.    import org.flintparticles.counters.Blast;
  11.    import org.flintparticles.emitters.Emitter;
  12.    import org.flintparticles.initializers.ImageClasses;
  13.    import org.flintparticles.initializers.Lifetime;
  14.    import org.flintparticles.initializers.Position;
  15.    import org.flintparticles.initializers.Velocity;
  16.    import org.flintparticles.renderers.DisplayObjectRenderer;
  17.    import org.flintparticles.zones.MultiZone;
  18.    import org.flintparticles.zones.RectangleZone;
  19.    
  20.    public class PowerupReshuffle extends Powerup
  21.    {
  22.        
  23.       
  24.       protected const NUM_PARTICLES:int = 100;
  25.       
  26.       internal var _dressupform:DressupForm;
  27.       
  28.       internal var _renderer:DisplayObjectRenderer;
  29.       
  30.       protected const PARTICLE_SPEED:int = 25;
  31.       
  32.       internal var _emitter:Emitter;
  33.       
  34.       protected const ZONE_WIDTH:int = 50;
  35.       
  36.       public function PowerupReshuffle()
  37.       {
  38.          super();
  39.          _sName = "reshuffle";
  40.          _sDescription = "Replaces current selection of clothing";
  41.       }
  42.       
  43.       override public function spawn() : Powerup
  44.       {
  45.          return new PowerupReshuffle();
  46.       }
  47.       
  48.       protected function eraseEffect() : void
  49.       {
  50.          _emitter.pause();
  51.          _dressupform.removeChild(_renderer);
  52.          _emitter = null;
  53.          _renderer = null;
  54.       }
  55.       
  56.       override public function activate(param1:Array, param2:Array, param3:DressupForm, param4:DressupLevelInfo) : void
  57.       {
  58.          var _loc5_:MultiZone = null;
  59.          var _loc6_:ClothingSlot = null;
  60.          super.activate(param1,param2,param3,param4);
  61.          param3.fillSlots(true);
  62.          SoundManager.getInstance().playSound("PowerupRandomizeSound");
  63.          _emitter = new Emitter();
  64.          _emitter.counter = new Blast(NUM_PARTICLES);
  65.          _emitter.addInitializer(new ImageClasses([KintabLarge,KintabSmall]));
  66.          _emitter.addInitializer(new Lifetime(0.1,3));
  67.          _emitter.addAction(new Age());
  68.          _emitter.addAction(new Fade());
  69.          _loc5_ = new MultiZone();
  70.          for each(_loc6_ in param1)
  71.          {
  72.             if(_loc6_.hasPart())
  73.             {
  74.                _loc5_.addZone(new RectangleZone(_loc6_.x - ZONE_WIDTH / 2,_loc6_.y - ZONE_WIDTH / 2,_loc6_.x + ZONE_WIDTH / 2,_loc6_.y + ZONE_WIDTH / 2));
  75.             }
  76.          }
  77.          _emitter.addInitializer(new Position(_loc5_));
  78.          _emitter.addInitializer(new Velocity(new RectangleZone(-PARTICLE_SPEED,-PARTICLE_SPEED,0,0)));
  79.          _emitter.addAction(new Accelerate(0,-30));
  80.          _emitter.addAction(new Move());
  81.          _renderer = new DisplayObjectRenderer();
  82.          _emitter.renderer = _renderer;
  83.          _dressupform = param3;
  84.          param3.addChild(_renderer);
  85.          _emitter.start();
  86.          setTimeout(eraseEffect,3000);
  87.       }
  88.    }
  89. }
  90.